#ifndef __SIMPLEFILE_PROTOCOL_ENGINE_H__
#define __SIMPLEFILE_PROTOCOL_ENGINE_H__ 1

#include <fstream>
#include <string>

#include "types.h"
#include "stegio.h"
#include "properties_reader.h"

#define LENGTH_FIELD_LENGTH 4


/**
 * @brief simple protocol engine for transmission of file payload
 * @author gpitsch and rpoisel
 * @note capable to operate in full duplex
 *
 * there is no check for end-of-file condition on the receiver
 * side since only file raw file payload without length
 * information is transmitted
 */
class CSimplefileProtocolEngine : public IStegIO
{
public:

	/**
	 * @param pFilenameRead file containing the data that is @b sent
	 * @param pFilenameWrite file containing the data that is @b received
	 */
	CSimplefileProtocolEngine(CPropertiesReader* pConfig);
	virtual ~CSimplefileProtocolEngine();

	virtual bool open();
	virtual void close();
	virtual NStegIO::EReadState read(unsigned char& pByte);
	virtual void write(unsigned char pByte);
	virtual int available();

	static const std::string sDefaultReadFilename;
	static const std::string sDefaultWriteFilename;

private:
	CSimplefileProtocolEngine();
	CSimplefileProtocolEngine(const CSimplefileProtocolEngine& );
	CSimplefileProtocolEngine& operator=(const CSimplefileProtocolEngine& );

	static const std::string sIniSectionName;

	CPropertiesReader* mConfig;

	std::string mIOFilenameRead;
	std::string mIOFilenameWrite;
	std::ifstream mIOStreamRead;
	std::ofstream mIOStreamWrite;

	bool mSendEof;
};

#endif // __SIMPLEFILE_PROTOCOL_ENGINE_H__

